<template>
  <div class="photoInfo">
    <!-- head -->
    <van-panel
      class="my-panel"
      :title="photoInfo.title"
      :status="'阅读' + photoInfo.click + '次'"
    >
      <div class="content">
        {{ photoInfo.content }}
      </div>
    </van-panel>
    <div class="img-box">
      <img
        v-for="(item, index) in thumimages"
        :key="item.id"
        v-lazy="item.src"
        @click="preview(index)"
      />
    </div>
    <!-- comment -->
    <Comment :id="id"></Comment>
  </div>
</template>
<script>
import { ImagePreview } from 'vant';
import Comment from '@/components/Comment';
export default {
  props: ['id'],
  components: {
    Comment,
  },
  data() {
    return {
      photoInfo: {},
      thumimages: [],
    };
  },
  created() {
    this.getimageInfo();
    this.getThumImages();
  },
  methods: {
    async getimageInfo() {
      const res = await this.$http.getimageInfo(this.id);
      this.photoInfo = res.data.message;
    },

    async getThumImages() {
      const res = await this.$http.getThumImages(this.id);
      this.thumimages = res.data.message;
    },
    preview(startPosition) {
      let images = this.thumimages.map((item) => item.src);
      ImagePreview({
        images,
        startPosition,
      });
    },
  },
};
</script>
<style lang="scss" scoped>
.photoInfo {
  padding: 0px 10px;
  .van-cell__title {
    font-size: 16px;
    font-weight: 600;
  }
  .my-panel {
    margin-bottom: 10px;
  }
  .content {
    text-indent: 2em;
    font-size: 12px;
  }
  .img-box {
    display: flex;
    justify-content: space-between;
    img {
      width: 115px;
      height: 100px;
    }
  }
}
</style>
